<?php $a_p = $this->properties; ?>
<?php $c_item = $this->currentItem; ?>

<form class="cmsform" action="" method="post" >
    <input type="hidden" value="<?php echo $this->act?>" name="act"/>
    <input type="hidden" value="<?php echo $c_item['id']?>" name="id"/>
 	<table class="formtable">
	<thead>
            <tr><td class="tabletitle" colspan="3"><?php echo $a_p[H_Description::PAGE_TITLE] ?></td></tr>
		<tr><td>&nbsp;</td><td>&nbsp;</td><td>
		  <div class='alert'>
			<span class="warning">(*)</span> <?php echo $this->t('bat buoc nhap') ?>
		  </div>
		</td></tr>
	</thead>
	<tbody>
         <?php if(isset($a_p[H_Description::LANG])&&$this->act!=H_G::EDIT) :?>
		<tr>
                    <td class="caption"><?php echo $a_p[H_Description::LANG][H_Description::LABLE] ?></td>
			<td class="warning"></td>
                        <td width="*">
                            <select class="<?php echo $a_p[H_Description::LANG][H_Description::CLASST] ?>" id="lang" name="lang">
                                <?php foreach(H_G::$LANG as $key => $lang){
                                    if ($this->lg == $key)
                                        echo "<option selected=\"selected\" value='$key'>$lang</option>";
                                    else
                                        echo "<option value='$key'>$lang</option>";
                                }?>
                            </select><?php echo $this->required($a_p['lang']['class'],$this->t('Phai chon ngon ngu truoc khi nhap.')) ?>
                        </td>
		</tr>
         <?php else: ?>
                <tr>
			<td class="caption"><?php echo $a_p[H_Description::LANG][H_Description::LABLE] ?></td>
			<td class="warning"></td>
                        <td width="*"><?php echo H_G::$LANG[$this->lg] ?>
                        </td>
		</tr>
         <?php endif; ?>
         <?php if(isset($a_p['title'])) :?>
		<tr>
			<td class="caption"><?php echo $a_p['title']['lable'] ?></td>
			<td class="warning"></td>
                        <td width="*"><input class="<?php echo $a_p['title']['class'] ?>" value="<?php echo $c_item['title']; ?>" type="text" id="title" name="title" /><?php echo $this->required($a_p['title']['class'],$a_p['title']['required_text']) ?></td>
		</tr>
         <?php endif; ?>
         
         <?php if(isset($a_p['order'])) :?>
		<tr>
			<td class="caption"><?php echo $a_p['order']['lable'] ?></td>
			<td class="warning"></td>
                        <td width="*"><input class="<?php echo $a_p['order']['class'] ?>" value="<?php echo $c_item['order'] ?>" type="text" id="order" name="order" />
                        <?php echo $this->required($a_p['order']['class'],$a_p['order'][H_Description::REQUIRED_TEXT]) ?>
                        </td>
		</tr>
         <?php endif; ?>
         <?php if(isset($a_p['keyword'])) :?>
                <tr>
                    <td class="caption"><?php echo $a_p['keyword']['lable'] ?>
                    </td>
                    <td class="warning"></td>
                    <td width="*">                        
                        <?php echo $this->action('getlistforallpage','keyword','cms',array('keyword'=>$c_item['keyword'],'cController'=>$this->cController,'cAction'=>$this->cAction)) ?>
                        <div><?php echo $this->required($a_p['keyword']['class'],$a_p['keyword'][H_Description::REQUIRED_TEXT]) ?></div>
                    </td>
		</tr>
         <?php endif; ?>
         <?php if(isset($a_p['status'])) : //STATUS
             if ($this->act==H_G::ADD){
                 $checked = "checked='checked'";
             }elseif ($c_item['status'] == H_B::STATUS_ON){
                 $checked = "checked='checked'";
             }else{
                 $checked = "";
             }
         ?>
                <tr>
                        <td class="caption"><?php echo $a_p['status']['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><input <?php echo $checked?> class="statusclass <?php echo $a_p['status']['class'] ?>" value="<?php echo H_B::STATUS_ON ?>" type="checkbox" id="status" name="status" /><span></span></td>
                </tr>
         <?php endif; ?>
         <?php if(isset($a_p['categories'])) :?>
                <tr>
                    <td colspan="3">
                        <?php echo $this->action($a_p['categories']['action'],$a_p['categories']['controller'],$a_p['categories']['module'],
                                                    array('lable'=>$a_p['categories']['lable'],
                                                          'lg'=>$this->lg,
                                                          'id'=>$c_item['id'],                                                          
                                                          H_Description::CATE_SHOW_TYPE => $a_p['categories'][H_Description::CATE_SHOW_TYPE],
                                                          H_Description::SHOW_FOR => $a_p['categories'][H_Description::SHOW_FOR]
                                                        )); ?>
                        <div><?php echo $this->required($a_p['categories']['class'],$a_p['categories'][H_Description::REQUIRED_TEXT]) ?></div>
                    </td>
		</tr>
         <?php endif; ?>

         <?php if(isset($a_p['p'])) : //Properties?>
                <tr>
                    <td colspan="3" style="border-bottom: 1px dotted"></td>
                </tr>
                <tr>
                    <td colspan="3" style="padding-left: 15px;font-size: 14px;"><strong><?php echo $a_p['p'][H_Description::TITLE] ?></strong></td>
                </tr>
              <?php foreach($a_p['p'] as $key => $item) :
                  if ($key == H_Description::TITLE) continue;
              ?>
                 <tr>
                        <td class="caption"><?php echo $item['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><input class="<?php echo $item['class'] ?>" value="<?php echo $c_item[$key]; ?>" type="text" id="title" name="<?php echo $key ?>" /><?php echo $this->required($item['class'],$item['required_text']) ?></td>
                </tr>
              <?php endforeach; ?>
	<?php endif; ?>
<!-- Sort Description -->
         <?php if(isset($a_p['sr'])) : //Properties?>
                <tr>
                    <td colspan="3" style="border-bottom: 1px dotted"></td>
                </tr>
                <tr>
                    <td colspan="3" style="padding-left: 15px;font-size: 14px;"><strong><?php echo $a_p['sr'][H_Description::TITLE] ?></strong></td>
                </tr>
              <?php foreach($a_p['sr'] as $key => $item) :
                  if ($key == H_Description::TITLE) continue;
              ?>
                 <tr>
                        <td class="caption"><?php echo $item['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><textarea class="<?php echo $item['class']; ?>" name="<?php echo $key ?>"><?php echo $c_item[$key]; ?></textarea>
                            <div><?php echo $this->required($item['class'],$item[H_Description::REQUIRED_TEXT]) ?></div>
                        </td>
                </tr>
              <?php endforeach; ?>
	<?php endif; ?>

         <?php if(isset($a_p['img'])) : //IMAGE?>
                <tr>
                    <td colspan="3" style="border-bottom: 1px dotted"></td>
                </tr>
                <tr>
                    <td colspan="3" style="padding-left: 15px;font-size: 14px;"><strong><?php echo $a_p['img'][H_Description::TITLE] ?></strong></td>
                </tr>
                <?php foreach($a_p['img'] as $key => $item):
                    if ($key == H_Description::TITLE) continue;
                ?>
                 <tr>
                        <td class="caption"><?php echo $item['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><?php echo $this->ckfinder($key,  H_View_Helper_Ckfinder::IMAGE,$c_item[$key],true) ?><?php echo $this->required($item['class'],$item['required_text']) ?></td>
                </tr>
              <?php endforeach; ?>
	<?php endif; ?>

        <?php if(isset($a_p['f'])) : //FILE?>
                <tr>
                    <td colspan="3" style="border-bottom: 1px dotted"></td>
                </tr>
                <tr>
                    <td colspan="3" style="padding-left: 15px;font-size: 14px;"><strong><?php echo $a_p['f'][H_Description::TITLE] ?></strong></td>
                </tr>
              <?php foreach($a_p['f'] as $key => $item) :
                  if ($key == H_Description::TITLE) continue;
              ?>
                 <tr>
                        <td class="caption"><?php echo $item['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><?php echo $this->ckfinder($key,  H_View_Helper_Ckfinder::FILE,$c_item[$key],true,array('class'=>$item['class'])) ?><?php echo $this->required($item['class'],$item['required_text']) ?></td>
                </tr>
              <?php endforeach; ?>
	<?php endif; ?>

        <?php if(isset($a_p['r'])) : //Properties?>
                <tr>
                    <td colspan="3" style="border-bottom: 1px dotted"></td>
                </tr>
                <tr>
                    <td colspan="3" style="padding-left: 15px;font-size: 14px;"><strong><?php echo $a_p['r'][H_Description::TITLE] ?></strong></td>
                </tr>
              <?php foreach($a_p['r'] as $key => $item) :
                  if ($key == H_Description::TITLE) continue;
              ?>
                 <tr>
                        <td class="caption"><?php echo $item['lable'] ?></td>
                        <td class="warning"></td>
                        <td width="*"><?php echo $this->editor($key, html_entity_decode($c_item[$key], ENT_QUOTES, "UTF-8"),array("class" => $item['class']),  $item[H_Description::EDITOR_TYPE],$item[H_Description::SAMPLEDATA])?>
                         <div><?php echo $this->required($item['class'],$item[H_Description::REQUIRED_TEXT]) ?></div>
                        </td>
                </tr>
              <?php endforeach; ?>
	<?php endif; ?>

	</tbody>
	<tfoot>
		<tr><td colspan="3"><button type="submit"><?php echo $this->t('Save Infomation'); ?></button><button type="reset"><?php echo $this->t('Reset'); ?></button></td></tr>
	</tfoot>
	</table>
</form>

<?php echo $this->headScript()->captureStart(); ?>
    $(document).ready(function(){
        if ($(".statusclass").attr('checked')){
            $(".statusclass").next().html("&nbsp;<?php echo $this->t('hien thi') ?>");
        }else{
            $(".statusclass").next().html("&nbsp;<?php echo $this->t('tam khoa') ?>");
        }
    });
    $(".statusclass").change(function(){        
        if ($(this).attr('checked')){
            $(this).next().html("&nbsp;<?php echo $this->t('hien thi') ?>");
        }else{
            $(this).next().html("&nbsp;<?php echo $this->t('tam khoa') ?>");
        }
    });
    <?php
        $font = Zend_Controller_Front::getInstance();
        $request = $font->getRequest();
        $href = $request->getModuleName()."/".$request->getControllerName()."/".$request->getActionName();
    ?>
    $("#lang").change(function(){        
        window.location.href = '/<?php echo $href; ?>/lg/'+$(this).val();
    });
<?php echo $this->headScript()->captureEnd(); ?>
